package com.ymk.cmd;

import com.ymk.base.cmd.ACmd;
import com.ymk.base.cmd.CmdSign;
import com.ymk.base.utlis.ParamsBuilder;
import com.ymk.bo.user.MchDeskBO;
import com.ymk.core.code.cmd.UserCmdCode;
import com.ymk.service.IMchDeskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

@Service
public class MchDeskGetCmd extends ACmd {

    @Override
    public CmdSign executeMop(HttpServletRequest request, CmdSign sign) throws Exception {
        CmdSign respSign = new CmdSign(sign);
        MchDeskBO reqData = super.getData(sign, MchDeskBO.class);

        ParamsBuilder paramsBuilder = ParamsBuilder.newBuild()
                .addParam("id", reqData.getId())
                .addParam("mchId", sign.getMchId())
                .setReturnStruct(sign.getReturnStruct());
        MchDeskBO respData = this.mchDeskService.get(paramsBuilder.build());
        respSign.setSource(super.getSource(respData));

        return respSign;
    }

    @Override
    public CmdSign executeStore(HttpServletRequest request, CmdSign sign) throws Exception {
        CmdSign respSign = new CmdSign(sign);
        MchDeskBO reqData = super.getData(sign, MchDeskBO.class);

        ParamsBuilder paramsBuilder = ParamsBuilder.newBuild()
                .addParam("id", reqData.getId())
                .addParam("mchId", sign.getMchId())
                .setReturnStruct(sign.getReturnStruct());
        MchDeskBO respData = this.mchDeskService.get(paramsBuilder.build());
        respSign.setSource(super.getSource(respData));

        return respSign;
    }

    @Override
    public String getCmdCode() {
        return UserCmdCode.MCH_DESK_GET;
    }

    @Autowired
    private IMchDeskService mchDeskService;
}